import facade.*;
import java.util.*;
import ejb.session.*;
import javax.naming.*;

public class Ejb {
  private static Context context;
  private static SystemViewRemote systemView = null;
  private static CadastroEmpresaRemote cadastroEmpresa = null;
  private static GerenciaProjetoRemote gerenciaProjeto = null;
  private static ControleFuncionarioRemote controleFuncionario = null;

  static {
    try {
      Object obj;
      Hashtable h = new Hashtable();
      h.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      h.put(Context.PROVIDER_URL, "localhost");
      h.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
      context = new InitialContext(h);

      obj = context.lookup("SystemViewBean");
      SystemViewRemoteHome home0 = (SystemViewRemoteHome)javax.rmi.PortableRemoteObject.narrow(
        obj, SystemViewRemoteHome.class
      );
      systemView = home0.create();

      obj = context.lookup("CadastroEmpresaBean");
      CadastroEmpresaRemoteHome home1 = (CadastroEmpresaRemoteHome)javax.rmi.PortableRemoteObject.narrow(
        obj, CadastroEmpresaRemoteHome.class
      );
      cadastroEmpresa = home1.create();

      obj = context.lookup("GerenciaProjetoBean");
      GerenciaProjetoRemoteHome home2 = (GerenciaProjetoRemoteHome)javax.rmi.PortableRemoteObject.narrow(
        obj, GerenciaProjetoRemoteHome.class
      );
      gerenciaProjeto = home2.create();

      obj = context.lookup("ControleFuncionarioBean");
      ControleFuncionarioRemoteHome home3 = (ControleFuncionarioRemoteHome)javax.rmi.PortableRemoteObject.narrow(
        obj, ControleFuncionarioRemoteHome.class
      );
      controleFuncionario = home3.create();
      
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  public static SystemViewRemote getSystemView() {
    return systemView;
  }

  public static CadastroEmpresaRemote getCadastroEmpresa() {
    return cadastroEmpresa;
  }

  public static ControleFuncionarioRemote getControleFuncionario() {
    return controleFuncionario;
  }

  public static GerenciaProjetoRemote getGerenciaProjeto() {
    return gerenciaProjeto;
  }
}
